package com.leetcode;

import com.leetcode.common.TreeNode;

/**
 * 226. 翻转二叉树
 * 另一种写法
 *
 * @author fy
 * @date 2022-04-17 17:27
 */
public class Solution226_1 {

    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }

        invertTree(root.left);
        invertTree(root.right);

        TreeNode left = root.left;
        root.left = root.right;
        root.right = left;

        return root;
    }

}
